package cs4280.ass2.util;

import org.apache.commons.lang.StringUtils;

import cs4280.ass2.entity.Movie;
import cs4280.ass2.exception.ValidateException;

public class MovieUtils {
	
	public static void validate(Movie movie) throws ValidateException {
		if (StringUtils.isBlank(movie.getName())) {
			throw new ValidateException("message.error.validate.movie.name.empty");
		}
		if (StringUtils.isBlank(movie.getDescription())) {
			throw new ValidateException("message.error.validate.movie.description.empty");
		}
		if (StringUtils.isBlank(movie.getDirector())) {
			throw new ValidateException("message.error.validate.movie.director.empty");
		}
		if (StringUtils.isBlank(movie.getCast())) {
			throw new ValidateException("message.error.validate.movie.cast.empty");
		}
		if (movie.getDuration() <= 0) {
			throw new ValidateException("message.error.validate.movie.duration.lessThanZero");
		}
		if (StringUtils.isBlank(movie.getCategory())) {
			throw new ValidateException("message.error.validate.movie.category.empty");
		}
		if (StringUtils.isBlank(movie.getLanguage())) {
			throw new ValidateException("message.error.validate.movie.language.empty");
		}
		if (StringUtils.isBlank(movie.getTrailerUrl())) {
			throw new ValidateException("message.error.validate.movie.trailerUrl.empty");
		}
		if (StringUtils.isBlank(movie.getImageUrl())) {
			throw new ValidateException("message.error.validate.movie.imageUrl.empty");
		}
	}
}
